<?php

namespace easydis\APSBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Contrat
 *
 * @ORM\Table()
 * @ORM\Entity(repositoryClass="easydis\APSBundle\EntityRepository\ContratRepository")
 * @ORM\Entity @ORM\HasLifecycleCallbacks
 */
class Contrat
{
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;
    
    /**
     * @var string
     *
     * @ORM\Column(name="date_fin", type="string", nullable=true)
     */
    private $date_fin;
    
    /**
     * @var string
     *
     * @ORM\Column(name="date_debut", type="string")
     */
    private $date_debut;
    
    /**
     * @var date
     *
     * @ORM\Column(name="date_fin_eng", type="date", nullable=true)
     */
    private $date_fin_eng;
    
    /**
     * @var date
     *
     * @ORM\Column(name="date_debut_eng", type="date")
     */
    private $date_debut_eng;
    
    /**
     * @ORM\ManyToOne(targetEntity="easydis\APSBundle\Entity\TypeContrat")
     * @ORM\JoinColumn(nullable=false)
     */
    private $typecontrat;
    
    /**
     * Set typecontrat
     *
     * @param easydis\APSBundle\Entity\TypeContrat $typecontrat
     */
    public function setTypeContrat(\easydis\APSBundle\Entity\TypeContrat $typecontrat)
    {
            $this->typecontrat = $typecontrat;
    }

    /**
     * Get typecontrat
     *
     * @return easydis\APSBundle\Entity\TypeContrat
     */
    public function getTypeContrat()
    {
        return $this->typecontrat;
    }

    public function __construct() {
        
    }
    
    /** @ORM\PrePersist */
    function onPersist() {
        // set default date
        /*$this->date_debut_eng = date_create_from_format('d/m/Y', $this->date_debut);
        if($this->date_fin != null)
            $this->date_fin_eng = date_create_from_format('d/m/Y', $this->date_fin);
        else
            $this->date_fin_eng = null;*/
    }
    
    /**
     * Get date_fin_eng
     *
     * @return date 
     */
    public function getDateFinEng()
    {
        return $this->date_fin_eng;
    }
    
    /**
     * Get date_debut_eng
     *
     * @return date
     */
    public function getDateDebutEng()
    {
        return $this->date_debut_eng;
    }
    
    /**
     * Set date_fin
     *
     * @return string 
     */
    public function setDateFin($date_fin)
    {
        $this->date_fin = $date_fin;
        $this->date_fin_eng = date_create_from_format('d/m/Y', $date_fin);
        return $this;
    }
    
    /**
     * Get date_fin_eng
     *
     * @return string 
     */
    public function getDateFin()
    {
        return $this->date_fin;
    }
    
    /**
     * Get date_debut
     *
     * @return contrat 
     */
    public function setDateDebut($date_debut)
    {
        $this->date_debut = $date_debut;
        $this->date_debut_eng = date_create_from_format('d/m/Y', $date_debut);
        return $this;
    }
    
    /**
     * Get date_debut_eng
     *
     * @return string
     */
    public function getDateDebut()
    {
        return $this->date_debut;
    }

    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }
}
